module ui {
    export class ScoreView extends egret.Sprite {

        private myScoreTxt: ImageNumber;

        private score: number = 0;

        public constructor() {
            super();
            this.myScoreTxt = new ImageNumber(0, new GameSpriteSheet(manager.ResManager.getTexture("rthrtb_png")));
            this.addChild(this.myScoreTxt);
            this.initUI();
        }

        public initUI() {
            this.updateScore(0);
        }

        public getScore(): number {
            return this.score;
        }

        public reset(): void {
            this.score = 0;
            this.updateScore(0);
        }

        public addCounter(count: number): void {
            this.score += count;
            this.updateScore(this.score);
        }

        public updateScore(score: number): void {
            this.score = score;
            this.myScoreTxt.setNb(this.score);
            let that = this;
            this.myScoreTxt.anchorOffsetX = this.myScoreTxt.width / 2;
            this.myScoreTxt.anchorOffsetY = this.myScoreTxt.height / 2;

            egret.Tween.get(this.myScoreTxt).to({scaleX: 2, scaleY: 2}, 200, egret.Ease.cubicOut).to({
                scaleX: 1,
                scaleY: 1
            }, 200, egret.Ease.cubicIn).call(function () {
                egret.Tween.removeTweens(that.myScoreTxt);
            });
        }
    }
}